package my_project

import my_project.business.{AppStatProcessor, AreaStatProcessor, LogETLProcessor, ProvinceCityStatProcessor}
import org.apache.spark.sql.SparkSession
import org.apache.commons.lang3.StringUtils
import org.apache.spark.internal.Logging

object SparkApp extends Logging{
  def main(args: Array[String]): Unit = {
    val spark: SparkSession = SparkSession.builder()
      //.appName("SparkApp")
      //.master("local")
      .getOrCreate()

    /**
     * 入参统计
     * 1）spark.time
     * 2)spark.raw.path
     * 3)spark.ip.path
     */
    val time: String = spark.sparkContext.getConf.get("spark.time")
    if (StringUtils.isBlank(time)){
      logError("处理批次不能为空......")
      System.exit(0)
    }

    //STEP1: ETL
    LogETLProcessor.process(spark)

    //STEP2:省份地市统计
    ProvinceCityStatProcessor.process(spark)

    //STEP3:统计地域分布情况
    AreaStatProcessor.process(spark)

    //STEP4:统计APP分布情况
    AppStatProcessor.process(spark)

    //Thread.sleep(200000)

    spark.stop()

  }

}
